Repository navigation
Block: Use getUsers with capability query - #12615
Conversation
|
Plugin builds for ff81376 are ready 🛎️!
|
|
Size Change: +45 B (0%) Total Size: 2.72 MB ℹ️ View Unchanged
|
|
So IIUC this replaces the deprecated But in WP 5.9 Because then we can get rid of the workaround in So something like const { authors } = useSelect(
(select) => {
const { getUsers, getPostType } = select(coreStore);
const capabilities = getPostType('web-story')?.capabilities['edit_posts'];
const query = {
search: authorKeyword,
capabilities,
};
return {
authors: getUsers(query),
};
},
[authorKeyword]
);Uses optional chaining for the Because of that, probably actually better to do this: const { authors } = useSelect(
(select) => {
const { getUsers, getPostType } = select(coreStore);
const capabilities = getPostType('web-story')?.capabilities['edit_posts'];
const query = {
search: authorKeyword,
capabilities,
};
return {
// Only load users when capability has been fetched already.
authors: capabilities ? getUsers(query) : [],
};
},
[authorKeyword]
); |
|
@swissspidy Your fix seems to work. Should I remove this |
|
Yes |
Done |
getUsers with capability query
swissspidy
left a comment
There was a problem hiding this comment.
Just needs QA instructions for regression testing
|
ReCreated this issue on stories-QA using Confirmed the fix via QA Note: When the author drop down is pressed, the cover image seems to hide the authors list @swissspidy @spacedmonkey - is it within scope of this ticket to ensure that the select-story :: drop down of the authors list should be visible ? |
|
No, not at all. Styling fixes are in progress at #12649 |
Context
Summary
Replace
getAuthorswithgetUsers.Followed this example - WordPress/gutenberg#33695
Relevant Technical Choices
To-do
User-facing changes
Testing Instructions
This PR can be tested by following these steps:
Reviews
Does this PR have a security-related impact?
Does this PR change what data or activity we track or use?
Does this PR have a legal-related impact?
Checklist
Type: XYZlabel to the PRFixes #9240